package com.study.sfd.prescription.controller;

import com.study.common.utils.PageUtils;
import com.study.common.utils.R;
import com.study.sfd.prescription.entity.PrescriptionEntity;
import com.study.sfd.prescription.service.PrescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * prescription(处方)
 *
 * @author 王个球
 * @email wangdajunzy@163.com
 * @date 2021-11-12 13:48:21
 */
@RestController
@RequestMapping("prescription/prescription")
public class PrescriptionController {
    @Autowired
    private PrescriptionService prescriptionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("prescription:prescription:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = prescriptionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    // @RequiresPermissions("prescription:prescription:info")
    public R info(@PathVariable("id") Integer id){
		PrescriptionEntity prescription = prescriptionService.getById(id);

        return R.ok().put("prescription", prescription);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("prescription:prescription:save")
    public R save(@RequestBody PrescriptionEntity prescription){
		prescriptionService.save(prescription);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("prescription:prescription:update")
    public R update(@RequestBody PrescriptionEntity prescription){
		prescriptionService.updateById(prescription);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("prescription:prescription:delete")
    public R delete(@RequestBody Integer[] ids){
		prescriptionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
